package com.loveshes.springbootstudy1.service;

import com.loveshes.springbootstudy1.bean.entity.User;
import com.loveshes.springbootstudy1.bean.vo.UserVO;
import com.loveshes.springbootstudy1.mapper.UserMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author WangZhe
 * @Date 2021-12-18 22:42
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public void insert(UserVO userVO) {
        User user = new User();
        // user.setUsername(userVO.getUsername());
        // user.setPassword(userVO.getPassword());
        BeanUtils.copyProperties(userVO, user);
        user.setCreateDate(new Date());
        user.setModifyDate(new Date());
        userMapper.insert(user);
    }

    public void insertWithXml(UserVO userVO) {
        User user = new User();
        BeanUtils.copyProperties(userVO, user);
        user.setCreateDate(new Date());
        user.setModifyDate(new Date());
        userMapper.insertWithXml(user);
    }

}
